package com.mobimagic.lockscreen.view.material;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.FrameLayout;

public class MaterialRippleFrameLayout extends FrameLayout implements RippleAble {

    private MaterialRippleHolder materialRippleHolder = null;

    @Override
    public void setOnClickListener(OnClickListener l) {
        materialRippleHolder.setTargetClickListener(l);
    }

    public MaterialRippleFrameLayout(Context context) {
        this(context, null, 0);
    }

    public MaterialRippleFrameLayout(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public MaterialRippleFrameLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        materialRippleHolder = new MaterialRippleHolder();
        materialRippleHolder.init(context, attrs, defStyle, this);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        boolean superOnTouchEvent = super.onTouchEvent(event);
        return materialRippleHolder.onTouchEvent(event, superOnTouchEvent, isEnabled());
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        materialRippleHolder.onSizeChanged(w, h, oldw, oldh);

    }

    @Override
    public boolean isInEditMode() {
        return true;
    }

    @Override
    public void draw(Canvas canvas) {
        materialRippleHolder.draw(canvas);
    }

    @Override
    public void viewDraw(Canvas canvas) {
        super.draw(canvas);
    }

}
